//
//  MinePageHeaderCell.m
//  ShowYork
//
//  Created by hxh on 2020/8/26.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "MinePageHeaderCell.h"

@interface MinePageHeaderCell ()
@property (nonatomic,strong)UIImageView *headerImgView;
@property (nonatomic,strong)UILabel *nameLb;
@property (nonatomic,strong)UILabel *userIdLb;
@property (nonatomic,strong)UILabel *gradeLb;
@end

@implementation MinePageHeaderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}
- (void)setUI{
    self.headerImgView = [[UIImageView alloc]init];
    self.headerImgView.layer.cornerRadius = KScaleWidth(35);
    self.headerImgView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.headerImgView];
    
    [self.headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(KScaleWidth(70), KScaleWidth(70))).priorityHigh();
        make.top.equalTo(self.contentView).offset(20);
        make.bottom.equalTo(self.contentView).offset(-20);
        make.left.equalTo(self.contentView).offset(15);
    }];
    
    self.nameLb = [[UILabel alloc]init];
    self.nameLb.text = @"XXXX";
    self.nameLb.textColor = RGBA(35, 24, 21, 1);
    self.nameLb.font = font(18);
    [self.contentView addSubview:self.nameLb];
    
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headerImgView.mas_top).offset(15);
        make.left.equalTo(self.headerImgView.mas_right).offset(15);
    }];
    
    self.userIdLb = [[UILabel alloc]init];
    self.userIdLb.text = @"ID：xxxxx";
    self.userIdLb.textColor = RGBA(102, 102, 102, 1);
    self.userIdLb.font = font(14);
    [self.contentView addSubview:self.userIdLb];
    
    self.gradeLb = [[UILabel alloc]init];
    self.gradeLb.backgroundColor = RGBA(153, 153, 153, 1);
    self.gradeLb.text = @"高三";
    self.gradeLb.textColor = [UIColor whiteColor];
    self.gradeLb.font = font(14);
    self.gradeLb.layer.cornerRadius = 10;
    self.gradeLb.layer.masksToBounds = YES;
    self.gradeLb.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.gradeLb];
    
    [self.userIdLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nameLb.mas_bottom).offset(8);
        make.left.equalTo(self.nameLb);
    }];
    [self.gradeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nameLb);
        make.left.equalTo(self.nameLb.mas_right).offset(10);
        make.size.mas_equalTo(CGSizeMake(46, 20));
    }];
}
+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"MinePageHeaderCell";
    MinePageHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[MinePageHeaderCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    return cell;
}

- (void)setUserInfo:(UserInfoModel *)user{
    self.userIdLb.text = [NSString stringWithFormat:@"ID：%@",user.id];
    self.nameLb.text = user.userName;
    self.gradeLb.text = user.levelStr;
}




@end
